package com.example.photoview;

import javafx.scene.control.Alert;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author Lyh
 * @date 2022/4/14 19:58
 */
public class PasteAction {
    private HomeController homeController=(HomeController) ControllerUtil.controllers.get(HomeController.class.getSimpleName());
    ArrayList<ImageModel> sourceList = SelectionModel.getImageModels();//存放图片本身的List
    public PasteAction(ImageBox imageBox) throws IOException {

        System.out.println("sourceList:"+sourceList);
        if (sourceList.isEmpty()) {
            SelectedModel.setSourcePath((imageBox.getImageModel()).getImageFilePath());
            SelectedModel.setWaitingPasteNum(1);
        } else {
            SelectedModel.setSourcePath(sourceList);
            SelectedModel.setWaitingPasteNum(sourceList.size());
        }
        SelectedModel.paste(homeController.getCurrentPath());


        Alert alert = new Alert(Alert.AlertType.INFORMATION);
        alert.titleProperty().set("提示信息");
        alert.headerTextProperty().set("已粘贴");
        alert.showAndWait();
        homeController.pasteButton.setDisable(false);
        homeController.refreshImagesList(homeController.getSortComboBox().getValue());
    }
}
